package listener;

import java.util.List;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

import model.Type;
import service.TypeService;

//所有页面都可以展示类型
@WebListener
public class ApplicationListener implements ServletContextListener {

    private TypeService tService = new TypeService();
    /**
     * @see ServletContextListener#contextDestroyed(ServletContextEvent)
     */
    public void contextDestroyed(ServletContextEvent arg0)  {
        // TODO Auto-generated method stub
    }

    /**
     * @see ServletContextListener#contextInitialized(ServletContextEvent)
     */
    public void contextInitialized(ServletContextEvent arg0)  {
        List<Type> list = tService.selectAll();
        arg0.getServletContext().setAttribute("typeList", list);
    }

}
